package com.clstu.method;

public class ThreadState_ {
    public static void main(String[] args) throws InterruptedException {
        T3 t3 = new T3();
        System.out.println(t3.getName()+"   状态   "+t3.getState());//查看状态
        t3.start();
        while (t3.getState()!= Thread.State.TERMINATED){
            System.out.println(t3.getName()+"   状态   "+t3.getState());//查看状态
            Thread.sleep(500);
        }
        System.out.println(t3.getName()+"   状态   "+t3.getState());//查看状态

    }
}
class T3 extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println("hi   "+i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}